package org.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.example.common.Result;
import org.example.pojo.Address;
import org.example.service.AddressService;
import org.example.mapper.AddressMapper;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
* @author 13326
* @description 针对表【hards_address】的数据库操作Service实现
* @createDate 2025-01-11 09:49:27
*/
@Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address>
    implements AddressService{
@Resource
private AddressMapper addressMapper;
    @Override
    public Result getall(Integer userId){
        LambdaQueryWrapper<Address> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Address::getUserId,userId);
        List<Address> addresseslist=addressMapper.selectList(lambdaQueryWrapper);
        HashMap<String ,Object> hashMap=new HashMap<>();
        hashMap.put("data",addresseslist);
        return Result.ok(hashMap);

    }
    @Override
    public Result add(Address address){
        int rows=addressMapper.insert(address);
        return Result.ok("新增成功");
    }
    @Override
    public Result updateaddrress(Address address){
        int rows=addressMapper.updateById(address);
        return Result.ok("修改成功");

    }
    @Override
    public Result deleteById(Integer id){
        int rows=addressMapper.deleteById(id);
        return Result.ok("删除成功");
    }
}




